package com.oop.Demo04;

public class App4 {
    public static void main(String[] args) {
        //Object>Person>Student
        //Object>Person>Teacher
        //Object>String
        Object o = new Student();
        System.out.println(o instanceof Object);//true
        System.out.println(o instanceof Person);//true
        System.out.println(o instanceof Student);//true
        System.out.println(o instanceof Teacher);//false 同级
        System.out.println(o instanceof String);//false  不相干

        //类型转换 父(高) 子(低)
        Person p = new Student();

//      p.go();//需要将父类强制转换为子类才能,使用子类的方法
        Student s = (Student) p;
        s.run();

        //((Student)p).run();

        //子类转父类可能会丢失方法
        Student student = new Student();
        Person p1 = student;
//        p1.run();//run 丢失


    }
}

    